package reflect;


import reflect.annotation.AutoRunClass;

import java.io.File;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URISyntaxException;

public class Test2 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.person");
        Object obj = cls.newInstance();
        File dir = new File(
                Test2.class.getResource(".").toURI()
        );
        String packName = Test3.class.getPackage().getName();
        System.out.println(packName);

        File[] subs = dir.listFiles(f -> f.getName().endsWith(".class"));
        Method[] methods = cls.getDeclaredMethods();
        for (File sub : subs) {
            String fileNme = sub.getName();
            String className = fileNme.substring(0, fileNme.indexOf("."));
            System.out.println(className);
            boolean tf = cls.isAnnotationPresent(AutoRunClass.class);
            if (tf){
                System.out.println(className+":标注了！");
            }else {
                System.out.println(className+"没被标注！");
            }



//            for (Method method : methods) {
//                if (
//                        method.getParameterCount() == 0 &&
//                                method.getModifiers() == Modifier.PUBLIC
//                                && method.getName().contains("s")
//                ) {
//                    method.invoke(obj);
//                }
//
//            }
        }
    }
}
